#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <sys/ioctl.h>	/* ioctl */
#include <sys/stat.h>

#include "public.h"
#include "debug.h"

/*
 *	abstruct : GPIO16_3 io trigger
 */


/* ioctl command */
#define   MAGIC_NUMBER		't'
#define   RTK_TRIGGER_HIGH	_IO(MAGIC_NUMBER, 0x1)
#define   RTK_TRIGGER_LOW   _IO(MAGIC_NUMBER, 0x3)


int g_trigger_dev;

int trigger_open()
{
	g_trigger_dev = open(TRIGER_DEV, O_RDONLY);
	if (g_trigger_dev <= 0) {
		trace_dbg(DEBUG_MSG_LEVEL_ERROR, "trigger device open fail\n");
		exit(0);
	}

	return 0;
}

int trigger_jump()
{
	ioctl(g_trigger_dev, RTK_TRIGGER_HIGH);
	msleep(1000);
	ioctl(g_trigger_dev, RTK_TRIGGER_LOW);

	return 0;
}

